/**
 * Copyright 2011 Honeywell Federal Manufacturing & Technologies, LLC. This material was produced under U.S. Government
 * contract DE-ACO4-01AL66850, Honeywell Federal Manufacturing & Technologies, LLC, (FM&T) with the U. S. Department of
 * Energy for the operation of the Kansas City Plant . The U.S. Government has rights to use, reproduce, and distribute
 * this software.  NEITHER THE GOVERNMENT NOR Honeywell Federal Manufacturing & Technologies, LLC, MAKES ANY WARRANTY,
 * EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.  If software is modified to produce
 * derivative works, such modified software should be clearly marked, so as not to confuse it with the version available
 * from FM&T.
 *
 * Additionally, this program is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License Version 3 published by the Free Software Foundation. Accordingly, this program is distributed in
 * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this library.
 * If not, see http://www.gnu.org/licenses/.
 */
package org.braintrain.domain;

import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

/**
 * Base type for the simple file system implemented to care for and organize
 * the Media (see ValidBlobFileTypes for valid types).  This base class is meant
 * to be a link from the current item to its parent MediaDirectory (null if in the root directory).
 * Also, since every item needs a name, it stores the name of the item.
 * 
 * @author John Ericksen
 *
 */

@MappedSuperclass
public class FileManageable extends BrainTrainBase implements Comparable<FileManageable> {
    
    private static final long serialVersionUID = -4297485672920125525L;
    
    private String name;
    private MediaDirectory parent;
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public int compareTo(FileManageable fileManageable) {
        if(fileManageable != null)
        {
            return this.getName().toLowerCase().compareTo(fileManageable.getName().toLowerCase());
        }
        return 0;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    public MediaDirectory getParent() {
        return parent;
    }

    public void setParent(MediaDirectory parent) {
        this.parent = parent;
    }
}
